<%@ page pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<div class="box tabbedBox">
	<div class="header">
		<ul>
			<li class="current"><a href="#basicInfo">事件基本信息</a>
			</li>
			<li><a href="#incidentHandleHistory">历史处理过程（<label
					id="incidentHandleHistoryCount" style="color:red"></label>） </a>
			</li>
			<li><a href="#cusIncidentHistory">用户历史事件（<label
					id="cusIncidentHistoryCount" style="color:red"></label>）</a>
			</li>
			<li><a href="#relationProcess">关联流程（<label
					id="relationProcessCount" style="color:red"></label>）</a>
			</li>
			<li><a href="#cusIncidentMessage">相关消息（<label
					id="cusIncidentMessageCount" style="color:red"></label>）</a>
			</li>
		</ul>
		<h2>&nbsp;</h2>
	</div>
	<div style="padding:0" class="content tabbed">

		<div id="basicInfo">
			<div class="box no-border">
				<div class="header">
					<h3>
						事件编号：${model.code}&nbsp;&nbsp;状态：<span class="important-info">${model.status}</span>
					</h3>
				</div>
			</div>
			<div class="box" style="overflow: hidden">${processer }</div>

			<isperp:slmInfo slmId="${model.slmId }" objectId="${model.id }"></isperp:slmInfo>
			<jsp:doBody />
			<isperp:datalog businessId="${model.id }"></isperp:datalog>

		</div>
		<div id="incidentHandleHistory">
			<isperp:grid
				url="incident/incident/listHandleProcess?relationId=${model.id }"
				showSearchbar="false" gridId="incidentHandleProcessGrid2"
				showToolbar="false" rownumbers="false" height="auto"
				cusFormatterActions="false"
				loadComplete=" $('#incidentHandleHistoryCount').text( incidentHandleProcessGrid2.jqGrid.getGridParam('records'));">
				<isperp:column name="id" title="id" hidden="true"></isperp:column>
				<isperp:column name="reasonAnalyze" title="reasonAnalyze"
					hidden="true">
				</isperp:column>
				<isperp:column name="solution" title="solution" hidden="true">
				</isperp:column>
				<isperp:column name="handleProcess" title="处理过程"
					isFormatterFun="true"
					formatter="return formatHandleProcess(rowObject);">
				</isperp:column>
				<isperp:column name="handlerName" title="处理人" hidden="true">
				</isperp:column>
				<isperp:column name="modifyDate" title="处理时间" hidden="true">
				</isperp:column>
			</isperp:grid>
		</div>
		<div id="cusIncidentHistory">
			<div class="box no-border">
				<div class="header">
					<h3>用户历史事件（按时间顺序，抓出其历史的报障记录；根据关键字从其病历中检索，如有匹配则红色显示）</h3>
				</div>
				<isperp:grid
					url="incident/incident/listByCusUser?cusUserId=${model.cusUserId }"
					showSearchbar="false" gridId="userIncidentHistoryGrid" rowNum="10"
					height="auto" showPager="true" cusFormatterActions="false"
					showToolbar="false" cusViewUrl="incident/incident/view"
					loadComplete=" $('#cusIncidentHistoryCount').text( userIncidentHistoryGrid.jqGrid.getGridParam('records'));">
					<isperp:column name="id" title="id" hidden="true"></isperp:column>
					<isperp:column name="code" title="事件编号" width="100">
					</isperp:column>
					<isperp:column name="description" title="描述" width="300">
					</isperp:column>
					<isperp:column name="createDate" title="报障时间" width="120">
					</isperp:column>
					<isperp:column name="status" title="处理状态" width="55">
					</isperp:column>
					<isperp:column name="solverName" title="处理人" width="60"
						align="center">
					</isperp:column>
				</isperp:grid>
			</div>
		</div>
		<div id="relationProcess">
			<isperp:processRelation businessKey="${model.id }" readonly="true"
				processKey="incidentProcess" projectIdControl="projectId"
				showTotalControl="relationProcessCount"></isperp:processRelation>

		</div>
		<div id="cusIncidentMessage">
			<div class="box no-border">
				<div class="header">
					<h3>消息记录</h3>
				</div>
				<isperp:grid
					url="app/message/listBySourceId?all=1&sourceId=${model.id }"
					showSearchbar="false" gridId="userIncidentMessageGrid"
					cusViewUrl="app/message/view" cusDialogSize="normal"
					showToolbar="true"
					loadComplete=" $('#cusIncidentMessageCount').text( userIncidentMessageGrid.jqGrid.getGridParam('records'));">
					<jsp:attribute name="toolbar">
						（备注：消息发送后不会即时显示在列表中）<isperp:button id="userIncidentMessageCreate"
							icon="icon-download" text="发送消息"
							onclick="isperp.openDialog({contentUrl:'app/message/sender/sendEdit?sourceId=${model.id }'})"></isperp:button>
					</jsp:attribute>
					<jsp:body>
						<isperp:column name="id" title="id" hidden="true"></isperp:column>
						<isperp:column name="sender_name" title="发送人" width="80">
						</isperp:column>
						<isperp:column name="receiver_name" title="接收人" width="80">
						</isperp:column>
						<isperp:column name="content" title="内容" width="300">
						</isperp:column>
						<isperp:column name="message_type" title="发送方式" width="70"
							isFormatterFun="true"
							formatter="if('LEAVEMSG'==cellvalue){return '留言';}else{return cellvalue;}">
						</isperp:column>
						<isperp:column name="create_date" title="发送时间" width="110">
						</isperp:column>
				</jsp:body></isperp:grid>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	function formatHandleProcess(rowObject) {
		var html;
		html = "<div style='padding:0' class='content tabbed'><div class='ci-failure-info'>";
		html = html + "<table class='comment' style='width:100%'>";

		html = html + "<tr>";
		html = html + "<td class='header' colspan='2'>处理人：" + rowObject.handlerName + "&nbsp;&nbsp处理时间：" + rowObject.modifyDate;
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "<tr>";
		html = html + "<td class='tdCaption'>原因分析：";
		html = html + "</td>";
		html = html + "<td class='tdContent'>" + rowObject.reasonAnalyze;
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "<tr>";
		html = html + "<td class='tdCaption'>解决方案：";
		html = html + "</td>";
		html = html + "<td class='tdContent'>" + rowObject.solution;
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "<tr>";
		html = html + "<td class='tdCaption'>处理过程：";
		html = html + "</td>";
		html = html + "<td class='tdContent'>" + rowObject.handleProcess;
		html = html + "</td>";
		html = html + "</tr>";

		html = html + "</table></div></div>";
		return html;

	}
	function printIncident(id) {
		var tempTitle = "打印事件单";
		var tempUrl = "ReportServer?reportlet=incident/cpt_incident_print.cpt&op=write&incident_id=" + id;
		var options = {
			title : tempTitle,
			contentUrl : tempUrl
		};
		isperp.openDialog(options);
	}
</script>
